

import pytest
import allure
import new_dispatch.src.test_case.front_salary.test_param as TP
from new_dispatch.util.decorator_wraps import decoratorWraps
from new_dispatch.src.test_api.front_salary.salary_base_api import salaryBaseApi
from new_dispatch.src.common.download_file import downloadFile
from new_dispatch.src.test_api.front_login import logginApi

import sys,os

sys.path.append(os.path.realpath(os.path.dirname(__file__) + "/../../../../"))
# from baoutils.sso import YonggongLogin

salary_base_api = salaryBaseApi()
download_file = downloadFile()


class TestFrontSalaryCase():
    """
    用功大厅 - 薪资管理 测试用例

    """

    def setup_class(self):
        """
        此类用例前 只执行一次
        :return:
        """
        salary_base_api.baoxian_project_login(TP.LOGIN_INFO)
        salary_base_api.choose_company(TP.LOGIN_INFO)
        salary_base_api.get_token()
        salary_base_api.sso_token()

    def teardown_class(self):
        """
        此类用例后 只执行一次
        :return:
        """
        pass

    def setup_method(self):
        """
        此类每个用例前 只执行一次
        :return:
        """
        pass

    def teardown_method(self):
        """
        此类每个用例后 只执行一次
        :return:
        """
        pass

    @decoratorWraps.logging
    @allure.title('薪资管理 基础流程')
    @allure.severity(allure.severity_level.NORMAL)
    @pytest.mark.run(order=1)

    @pytest.mark.parametrize('case_param', TP.TEST_001_CASE_PARAM)
    def test_001_salary_order_base_process(self, case_param):
        """
        薪资管理 基础流程
        :return:
        """

        # salary_base_api.baoxian_project_login(TP.LOGIN_INFO)
        # salary_base_api.choose_company(TP.LOGIN_INFO)
        # salary_base_api.get_token()
        # salary_base_api.sso_token()

        # 创建薪资单
        salary_base_api.create_salary_order_api(case_param)

        # 薪资单下载模板
        # download_file.download_salary_excel_file(case_param)
        # 文件上传
        # print(case_param)
        # salary_api.file_upload_api(case_param)
        # 薪资表提交验证
        # salary_api.file_validate_api()
        # 薪资表提交核算
        # salary_order_api.check_salary_order_api()
        # 提交支付
        # salary_order_api.pay_salary_order_api()

if __name__ == '__main__':
    case_param = {
        # 发薪月份
        "salary_month": "2021-06",
        # 发薪日期
        "salary_date": "2021-06-08",
        # 税款所属月份
        "tax_month": "2021-06",
        # 6:正常工资薪金,10:全年一次性奖金,2:劳务报酬,11:解除劳动合同一次性补偿金,7:非居民正常工资薪金,8:非居民数月奖金,9:非居民劳务报酬
        "income_item": '6',
        # 备注
        "remark": "自动化测试-正常工资薪金",
        # 业务类型
        "business_id": "2",
        #   2:劳务报酬,6:正常工资薪金,61正常工资薪金(手动上传),7:非居民正常工资薪金,8:非居民数月奖金,9:非居民劳务报酬,10:全年一次性奖金,11:解除劳动合同一次性补偿金
        "type": "6"
    }
    r = TestFrontSalaryCase()
    r.test_001_salary_order_base_process(case_param)